<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="utf-8">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="Content-Language" content="UTF-8" />
  <meta content="all" name="robots" />
  <meta name="author" content="tiger"/>
  <meta name="Copyright" content="jinzhou group" />
  <meta name="description" content="jinzhou group oa" />
  <title>部门权限</title>
</head>
<body>
<?php

$opt = $_GET["opt"];
if (!$opt)
{
   include("../../tools/mysql.php");
   db_connect();
   
   $sql = "SELECT pvalue FROM oa_pars WHERE pname='version'";
   $re = db_query_once($sql);
   $version = explode(" ", $re["pvalue"]);
?>
<h1>版本管理</h1>
<hr />
<form action="version.php?opt=1" method="post">
  <div>
	选择发布类型：
    <select id="v_release" name="v_release">
	  <option value="Developing" <?php echo option_is_selected("Developing"); ?> >Developing</option>
	  <option value="Alpha" <?php echo option_is_selected("Alpha"); ?> >Alpha</option>
	  <option value="Beta" <?php echo option_is_selected("Beta"); ?> >Beta</option>
	  <option value="Regular" <?php echo option_is_selected("Regular"); ?> >Regular</option>
	</select>
  </div>
  <div>
    输入版本号：
	<input id="v_num" name="v_num" type="text" value="<?php echo $version[1]; ?>" />
  </div>
  <div>
	输入内部密码：
	<input id="pwd" name="pwd" type="password" />
  </div>
  <input type="submit" value="提交" />
</form>

<?php
}
elseif ($opt == 1)
{
   $v_release = $_POST["v_release"];
   $v_num = $_POST["v_num"];
   $pwd = $_POST["pwd"];
   if ($pwd != "147852369") { echo "密码错误！"; exit(); }
   
   
   include("../../tools/mysql.php");
   db_connect();

   $sql = "UPDATE oa_pars SET pvalue='" . $v_release . " " . $v_num . "' WHERE pname='version'";
   $re = db_exec($sql);

   echo $re ? "提交成功！" : "提交失败！";
   echo "<br />";
   // echo "<a target=\"oa_frame_header\" href=\"../header.php\">刷新页面</a>";
   // echo "<script language=\"javascript\">window.open(\"../wp/header.php\", \"oa_frame_header\");</script>";
   echo "<script language=\"javascript\">parent.chVersion('" . $v_release . " " . $v_num . "');</script>";
}
?>
</body>
</html>

<?php
// 选项
function option_is_selected($str)
{
   global $version;
   return ($version[0] == $str ? " selected=\"selected\" " : "");
}

?>
